// 项目管理中心 - 所有项目数据都在这里统一管理
export const projectData = [
  {
    id: 1,
    name: 'KZ-DevOps平台开发',
    code: 'PROJ-001',
    description: '企业级DevOps平台开发项目，包含CI/CD、监控、日志等模块',
    status: '进行中',
    priority: '高',
    progress: 75,
    startDate: '2024-01-01',
    endDate: '2024-06-30',
    manager: '张项目经理',
    teamMembers: ['李开发', '王测试', '赵运维'],
    budget: 500000,
    actualCost: 375000,
    createdAt: '2024-01-01',
    updatedAt: '2024-03-15'
  },
  {
    id: 2,
    name: '移动端APP重构',
    code: 'PROJ-002',
    description: '现有移动端APP的技术重构和性能优化',
    status: '规划中',
    priority: '中',
    progress: 20,
    startDate: '2024-04-01',
    endDate: '2024-09-30',
    manager: '王产品经理',
    teamMembers: ['钱前端', '孙后端'],
    budget: 300000,
    actualCost: 60000,
    createdAt: '2024-02-15',
    updatedAt: '2024-03-10'
  },
  {
    id: 3,
    name: '大数据分析平台',
    code: 'PROJ-003',
    description: '构建企业级大数据分析和可视化平台',
    status: '已完成',
    priority: '高',
    progress: 100,
    startDate: '2023-09-01',
    endDate: '2024-02-29',
    manager: '陈架构师',
    teamMembers: ['周数据工程师', '吴算法工程师'],
    budget: 800000,
    actualCost: 720000,
    createdAt: '2023-09-01',
    updatedAt: '2024-02-29'
  },
  {
    id: 4,
    name: '微服务架构迁移',
    code: 'PROJ-004',
    description: '从单体架构迁移到微服务架构',
    status: '进行中',
    priority: '紧急',
    progress: 60,
    startDate: '2024-02-01',
    endDate: '2024-07-31',
    manager: '郑技术总监',
    teamMembers: ['冯开发', '陈开发', '褚测试'],
    budget: 600000,
    actualCost: 360000,
    createdAt: '2024-02-01',
    updatedAt: '2024-03-20'
  },
  {
    id: 5,
    name: '安全合规改造',
    code: 'PROJ-005',
    description: '系统安全合规性改造项目',
    status: '已暂停',
    priority: '中',
    progress: 40,
    startDate: '2024-01-15',
    endDate: '2024-05-31',
    manager: '卫安全专家',
    teamMembers: ['蒋开发', '沈测试'],
    budget: 200000,
    actualCost: 80000,
    createdAt: '2024-01-15',
    updatedAt: '2024-03-01'
  }
];

// 生成更多测试数据
for (let i = 6; i <= 50; i++) {
  const statuses: Array<'规划中' | '进行中' | '已暂停' | '已完成' | '已取消'> = ['规划中', '进行中', '已暂停', '已完成', '已取消'];
  const priorities: Array<'低' | '中' | '高' | '紧急'> = ['低', '中', '高', '紧急'];
  const managers = ['张项目经理', '王产品经理', '陈架构师', '郑技术总监', '卫安全专家'];
  const teamMembers = [
    ['李开发', '王测试', '赵运维'],
    ['钱前端', '孙后端'],
    ['周数据工程师', '吴算法工程师'],
    ['冯开发', '陈开发', '褚测试'],
    ['蒋开发', '沈测试']
  ];
  
  projectData.push({
    id: i,
    name: `项目${i}`,
    code: `PROJ-${i.toString().padStart(3, '0')}`,
    description: `项目${i}的描述信息`,
    status: statuses[Math.floor(Math.random() * statuses.length)],
    priority: priorities[Math.floor(Math.random() * priorities.length)],
    progress: Math.floor(Math.random() * 101),
    startDate: '2024-01-01',
    endDate: '2024-12-31',
    manager: managers[Math.floor(Math.random() * managers.length)],
    teamMembers: teamMembers[Math.floor(Math.random() * teamMembers.length)],
    budget: Math.floor(Math.random() * 1000000) + 100000,
    actualCost: Math.floor(Math.random() * 800000) + 50000,
    createdAt: '2024-01-01',
    updatedAt: '2024-03-15'
  });
}

// 项目进度概览数据
export const projectProgressData = {
  labels: ['1月', '2月', '3月', '4月', '5月', '6月'],
  datasets: [
    {
      label: '计划进度',
      data: [10, 25, 45, 65, 85, 100],
      borderColor: '#3b82f6',
      backgroundColor: 'rgba(59, 130, 246, 0.1)',
      tension: 0.4
    },
    {
      label: '实际进度',
      data: [8, 22, 40, 58, 75, 92],
      borderColor: '#10b981',
      backgroundColor: 'rgba(16, 185, 129, 0.1)',
      tension: 0.4
    }
  ]
};

// 项目状态统计数据
export const projectStatusData = {
  labels: ['规划中', '进行中', '已暂停', '已完成', '已取消'],
  datasets: [
    {
      label: '项目数量',
      data: [12, 18, 5, 8, 2],
      backgroundColor: [
        'rgba(59, 130, 246, 0.8)',
        'rgba(16, 185, 129, 0.8)',
        'rgba(245, 158, 11, 0.8)',
        'rgba(139, 92, 246, 0.8)',
        'rgba(239, 68, 68, 0.8)'
      ],
      borderColor: [
        'rgb(59, 130, 246)',
        'rgb(16, 185, 129)',
        'rgb(245, 158, 11)',
        'rgb(139, 92, 246)',
        'rgb(239, 68, 68)'
      ],
      borderWidth: 1
    }
  ]
};

// 获取项目统计数据
export const getProjectStats = (): ProjectStats => {
  const now = new Date();
  
  const stats: ProjectStats = {
    total: projectData.length,
    planning: projectData.filter(p => p.status === '规划中').length,
    inProgress: projectData.filter(p => p.status === '进行中').length,
    paused: projectData.filter(p => p.status === '已暂停').length,
    completed: projectData.filter(p => p.status === '已完成').length,
    cancelled: projectData.filter(p => p.status === '已取消').length,
    overdue: projectData.filter(p => {
      if (p.status === '已完成' || p.status === '已取消') return false;
      const endDate = new Date(p.endDate);
      return endDate < now;
    }).length,
    totalBudget: projectData.reduce((sum, p) => sum + (p.budget || 0), 0),
    totalCost: projectData.reduce((sum, p) => sum + (p.actualCost || 0), 0)
  };
  
  return stats;
};